<?php
/**
*
* @author chenping<chenping@shopex.cn>
* @version $Id: 2013-3-12 17:23Z
*/
class erpapi_shop_response_plugins_order_tbgift extends erpapi_shop_response_plugins_order_abstract
{

    public function convert(erpapi_shop_response_abstract $platform)
    {
        $tbgift = array();
        $gift_data = array();
        foreach($platform->_newOrder['order_objects'] as $objects){
            $gift_data[$objects['oid']] = $objects['price'];
        }
        if ('true' == app::get('ome')->getConf('ome.preprocess.tbgift')) {
            $other_list     = $platform->_ordersdf['other_list'];
            foreach($other_list as &$gift){
                $gift['price'] = $gift_data[$gift['oid']];
            }
            $tbgift['gift'] = $other_list;
            $tbgift['order_id'] = null;
        }

      return $tbgift;
    }

    /**
     *
     * @return void
     * @author 
     **/
    public function postCreate($order_id,$tbgift)
    {



      kernel::single('ome_preprocess_tbgift')->save($order_id,$tbgift['gift']);
    }
}